
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

//用于加载本地图片的工具类
class ImageUtils {
  static ImageProvider getAssetImage(String name) {
    return AssetImage(getImgPath(name));
  }

  static String getImgPath(String name) {
    if(name.startsWith("assets/images/")){
      name = name.substring(14);
    }
    if (name.startsWith('/')) {
      name = name.substring(1);
    }
    return 'assets/images/$name';
  }

  // static ImageProvider getImageProvider(String? imageUrl, {String holderImg = 'none'}) {
  //   if (TextUtil.isEmpty(imageUrl)) {
  //     return AssetImage(getImgPath(holderImg));
  //   }
  //   return CachedNetworkImageProvider(imageUrl!);
  // }
}
